package com.gxa.jd.controller;

import com.gxa.jd.pojo.Hotel;
import com.gxa.jd.service.HotelService;
import com.gxa.entity.PageResult;
import com.gxa.entity.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/hotel")
@Api(description = "酒店接口文档")
public class HotelController {

    @Autowired
    private HotelService hotelService;


    @GetMapping("/findAll")
    @ApiOperation(value = "查询所有酒店信息", notes = "查询所有酒店信息")
    public List<Hotel> findAll() {
        return hotelService.findAll();
    }

    @GetMapping("/findPage")
    @ApiOperation(value = "分页查询接口",notes = "分页查询接口")
    public PageResult<Hotel> findPage(int page, int size) {
        return hotelService.findPage(page, size);
    }

    @PostMapping("/findList")
    public List<Hotel> findList(@RequestBody Map<String, Object> searchMap) {
        return hotelService.findList(searchMap);
    }

    @PostMapping("/findPage")
    public PageResult<Hotel> findPage(@RequestBody Map<String, Object> searchMap, int page, int size) {
        return hotelService.findPage(searchMap, page, size);
    }

    @GetMapping("/findById")
    @ApiOperation(value = "根据id查询酒店信息",notes = "根据id查询酒店信息")
    public Hotel findById(Integer id) {
        return hotelService.findById(id);
    }


    @PostMapping("/add")
    @ApiOperation(value = "添加酒店",notes = "添加酒店")
    public Result add(@RequestBody Hotel hotel) {
        hotelService.add(hotel);
        return new Result();
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改酒店信息",notes = "修改酒店信息")
    public Result update(@RequestBody Hotel hotel) {
        hotelService.update(hotel);
        return new Result();
    }

    @GetMapping("/delete")
    @ApiOperation(value = "根据id删除酒店信息",notes = "根据id删除酒店信息")
    public Result delete(Integer id) {
        hotelService.delete(id);
        return new Result();
    }

}
